﻿using System;

namespace DataCoreTechnologies.SqlServer
{
   /// <summary>
   /// Indicates which category a system type is part of.
   /// </summary>
   public enum SystemTypeCategory
   {
     Undefined,
     ExactNumerics,
     ApproximateNumerics,
     DateAndTime,
     CharacterStrings,
     UnicodeCharacterStrings,
     BinaryStrings,
     CLRDataTypes,
     SpatialDataTypes,
     OtherDataTypes
   }

   /// <summary>
   /// Contains information about a datatype created by SqlServer.
   /// </summary>
   public sealed class SystemType
   {
      #region Public
      //Properties
      /// <summary>
      /// A number that uniquely identifies this class instance.
      /// </summary>
      public Guid InstanceId { get; internal set; }
      /// <summary>
      /// The database that this system type belongs to.
      /// </summary>
      public Database Database { get; private set; }
      /// <summary>
      /// The category that this system type is part of.
      /// </summary>
      public SystemTypeCategory Category { get; internal set; }
      /// <summary>
      /// A title used to refer to this system type within the database.
      /// </summary>
      public string Name { get; internal set; }
      /// <summary>
      /// When appropriate the maximum allowed size for this system type.
      /// </summary>
      public int MaxLength { get; internal set; }
      /// <summary>
      /// When appropriate the level of precision in this system type.
      /// </summary>
      public int Precision { get; internal set; }
      /// <summary>
      /// When appropriate the scale level in this system type.
      /// </summary>
      public int Scale { get; internal set; }
      /// <summary>
      /// When appropriate the name of the collation used by this system type.
      /// </summary>
      public string CollationName { get; internal set; }
      /// <summary>
      /// Indicator stating whether this system type allows null values.
      /// </summary>
      public Boolean IsNullable { get; internal set; }
      #endregion
      #region Internal
      //Constructor
      /// <summary>
      /// Creates a instance of a system type that belongs to the database indicated by the parameter.
      /// </summary>
      /// <param name="container">The database this system type belongs to.</param>
      internal SystemType(Database container)
      {
         Database = container;
         InstanceId = System.Guid.NewGuid();
      }
      //Properties
      /// <summary>
      /// A number used to uniquely identify this system type within the database.
      /// </summary>
      internal int Id { get; set; }
      #endregion
   }
}
